package cn.bld.web;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class SysInterceptor extends HandlerInterceptorAdapter {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        HttpSession session = request.getSession();
        if (null == session.getAttribute("userSession")) {
            System.out.println("访问终止");
            response.sendRedirect("/login.jsp");
            return false;
        }
        System.out.println("继续请求访问");
        return true;//表示可以继续放false不能继续访问
    }
}
